package com.boot.controller.user;

import com.boot.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private RedisTemplate<String, Object> redisTemplate;

    @Operation(summary = "查询营业状态")
    @GetMapping("shop/status")
    public Result getShopStatus() {
        Integer status = 1;
        if (Boolean.TRUE.equals(redisTemplate.hasKey("SHOP_STATUS"))) {
            status = (Integer) redisTemplate.opsForValue().get("SHOP_STATUS");
        } else {
            redisTemplate.opsForValue().set("SHOP_STATUS", 1);
        }
        return Result.success(status);
    }
}
